package com.kmist.jianghu;

import android.content.Context;
import android.content.Intent;
import android.widget.EditText;
import android.widget.RadioButton;

import TOOL.DialogRe;

public class CreatePlayerDialog extends DialogRe {

    EditText nameEdit;
    RadioButton manBtn, womanBtn;

    CreatePlayerDialog(Context context) {
        super(context, R.layout.a_login_02_dialog_newplayer);
        buttonOK("确定");
        Init();

        nameEdit = mWindow.findViewById(R.id.login_02_edit_newplayer);
        manBtn = mWindow.findViewById(R.id.login_02_radiobtn_man);
        womanBtn = mWindow.findViewById(R.id.login_02_radiobtn_woman);
        manBtn.setChecked(true);
    }

    public void sureEvent(){
        super.sureEvent();

        if(nameEdit.getText().toString().equals("")){
            MainActivity.Alarm("角色名不为空");
        }else{
            //创建角色
            String sex = "man";
            if(womanBtn.isChecked()){
                sex = "Woman";
            }

            //创建角色
            MainActivity.createNewPalyer(nameEdit.getText().toString(), sex);

            //跳转界面
            Intent intent = new Intent(mContext, JianHu.class);
            mContext.startActivity(intent);
        }
    }
}
